<?php
/**************************************************
* PluginLotto.com                                 *
* Copyrights (c) 2005-2010. iZAP                  *
* All rights reserved                             *
***************************************************
* @author iZAP Team "<support@izap.in>"
* @link http://www.izap.in/
* @version {version} $Revision: {revision}
* Under this agreement, No one has rights to sell this script further.
* For more information. Contact "Tarun Jangra<tarun@izap.in>"
* For discussion about corresponding plugins, visit http://www.pluginlotto.com/pg/forums/
* Follow us on http://facebook.com/PluginLotto and http://twitter.com/PluginLotto
 */

// geting query strings
$query = get_input('qry');
// getting entity from guid
$entity = get_entity($query[1]);
$session = func_get_session_byizap($entity->guid);
//$session = FALSE;
if(!$session && $entity) {
  // creating sessions for single time poll by per session
  func_add_session_byizap($entity->guid, true);
  // getting current option from query strings
  $current_option = $query[2];
  $voted_option = 'voted_' . $current_option;
  func_izap_update_metadata(array(
    'entity' => $entity,
    'metadata' => array(
      $voted_option => ($entity->$voted_option + 1),
      'total_votes' => ($entity->total_votes + 1),
    ),
  ));
}echo elgg_view('output/result_only', array( 'entity' => $entity));